﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace NCEdu.Web.fileInfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int fielId=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(fielId);
				}
			}
		}
			
	private void ShowInfo(int fielId)
	{
		NCEdu.BLL.fileInfo bll=new NCEdu.BLL.fileInfo();
		NCEdu.Model.fileInfo model=bll.GetModel(fielId);
		this.lblfielId.Text=model.fielId.ToString();
		this.txtfileName.Text=model.fileName.ToString();
		this.txtfileUpdateTime.Text=model.fileUpdateTime.ToString();
		this.txtfileSize.Text=model.fileSize;
		this.txtfileAuthor.Text=model.fileAuthor;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsDateTime(txtfileUpdateTime.Text))
			{
				strErr+="fileUpdateTime格式错误！\\n";	
			}
			if(this.txtfileSize.Text.Trim().Length==0)
			{
				strErr+="fileSize不能为空！\\n";	
			}
			if(this.txtfileAuthor.Text.Trim().Length==0)
			{
				strErr+="fileAuthor不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int fielId=int.Parse(this.lblfielId.Text);
			byte[] fileName= new UnicodeEncoding().GetBytes(this.txtfileName.Text);
			DateTime fileUpdateTime=DateTime.Parse(this.txtfileUpdateTime.Text);
			string fileSize=this.txtfileSize.Text;
			string fileAuthor=this.txtfileAuthor.Text;


			NCEdu.Model.fileInfo model=new NCEdu.Model.fileInfo();
			model.fielId=fielId;
			model.fileName=fileName;
			model.fileUpdateTime=fileUpdateTime;
			model.fileSize=fileSize;
			model.fileAuthor=fileAuthor;

			NCEdu.BLL.fileInfo bll=new NCEdu.BLL.fileInfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
